package cn.yunhe.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.yunhe.entity.Supp;
import cn.yunhe.entity.Type;
import cn.yunhe.service.TypeService;

@Controller
public class TypeController {
	@Autowired
	private TypeService typeService;

	@RequestMapping("/selectType")
	public String selectDrud(HttpServletRequest request) {
		System.out.println("1111111111111111111111");
		List<Type> type = typeService.selectType();
		request.setAttribute("typelist", type);
		return "Type";
	}
	
	@RequestMapping("/selectType1")
	public String selectDrud1(HttpServletRequest request) {
		System.out.println("1111111111111111111111");
		List<Type> type = typeService.selectType();
		request.setAttribute("typelist", type);
		return "TypeUpdateDeleate";
	}
	@RequestMapping("/selectSuppAndType")
	public String selectMoHuSupp(HttpServletRequest request, String tname) {
		System.out.println(tname);
		List<Type> type= typeService.selectSuppAndType(tname);
		request.setAttribute("typelist", type);
		return "Type";
	}
	@RequestMapping("/insertType")
	public String insertType(HttpServletRequest request ,Type type) {
		int num = typeService.insertType(new Type(type.getTname(),1,type.getPid()));
		return "redirect:selectType.do";
	}
	@RequestMapping("/updateType")
	public String updateType(HttpServletRequest request ,Type type) {
		int num = typeService.updateType(new Type(type.getTid(),type.getTname(),type.getPid()));
		return "redirect:selectType.do";
	}
	@RequestMapping("/updateDeleateType")
	public String updateDeleateType(HttpServletRequest request ,Type type) {
		int num = typeService.updateDeleateType(new Type(type.getTid(),type.getTstate()));
		return "redirect:selectType.do";
	}
	@RequestMapping("/weixin")
	public String weixin(HttpServletRequest request,String msg1 ) {
		System.out.println(msg1);
	request.setAttribute("msg1", msg1);
		return "../../WeiXin";
	}
	@RequestMapping("/zhifubao")
	public String zhifubao(HttpServletRequest request,String msg1 ) {
		System.out.println(msg1);
	request.setAttribute("msg1", msg1);
		return "../../zhifubao";
	}
	
	
	
	
	public TypeService getTypeService() {
		return typeService;
	}

	public void setTypeService(TypeService typeService) {
		this.typeService = typeService;
	}

}
